Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Test Coverage for Dominant Color Images Plugin #1837

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from

Conversation

sarthak-19
Copy link
Contributor

@sarthak-19 sarthak-19 commented Jan 30, 2025

Summary

This is part of #1789:

  • Ignore Coverage for Non-Critical Code Blocks
  • Add Missing @covers Annotations
  • Add Missing Tests
Before: 48.15% ⚠️ After: 82.00% ✅
image   image
   

cc : @westonruter

Copy link

codecov bot commented Jan 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.07%. Comparing base (d94977f) to head (af9f180).

Additional details and impacted files
@@            Coverage Diff             @@
##            trunk    #1837      +/-   ##
==========================================
+ Coverage   65.89%   67.07%   +1.18%     
==========================================
  Files          88       87       -1     
  Lines        6878     6873       -5     
==========================================
+ Hits         4532     4610      +78     
+ Misses       2346     2263      -83     
Flag Coverage Δ
multisite 67.07% <ø> (+1.18%) ⬆️
single 40.06% <ø> (+1.48%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@westonruter westonruter added no milestone PRs that do not have a defined milestone for release skip changelog PRs that should not be mentioned in changelogs [Plugin] Image Placeholders Issues for the Image Placeholders plugin (formerly Dominant Color Images) labels Jan 31, 2025
@@ -42,7 +42,7 @@ public function test_dominant_color_metadata( string $image_path, array $expecte
*
* @dataProvider provider_get_dominant_color
*
* @covers ::dominant_color_get_dominant_color
* @covers helper::dominant_color_get_dominant_color
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem right? The :: here refers to the global namespace.

Suggested change
* @covers helper::dominant_color_get_dominant_color
* @covers ::dominant_color_get_dominant_color

Copy link
Contributor Author

@sarthak-19 sarthak-19 Feb 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:: refers to the global namespace, and it works for rest of the functions however, when I'm trying to generate coverage report, for the functions where I've added helper & hooks it's showing 0 coverage without file reference.

Previous Result :

  • When setting annotation to * @covers ::dominant_color_get_dominant_color & * @covers ::dominant_color_img_tag_add_dominant_color

  • helper.php

image
  • hooks.php
image

New Result :

  • When setting annotation to * @covers helper::dominant_color_get_dominant_color & * @covers hooks::dominant_color_img_tag_add_dominant_color

  • helper.php

image
  • hooks.php
image

So how should I proceed with this since helper.php & hooks.php file don't have a class so ClassName:functionName annotations will not work I also tried adding namespace to helper.php & hooks.php but it results in failing all the test cases and throws error?

cc : @westonruter

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange. I don't know why that would be. I also don't understand adding hooks and helper to the beginning of those functions. They would seem to indicate there are classes called hooks and helper, which there aren't.

You're seeing this with local coverage report, but are you also seeing it with the Codecov coverage report?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They would seem to indicate there are classes called hooks and helper, which there aren't.

Exactly, still for some reason it seems to work.

You're seeing this with local coverage report, but are you also seeing it with the Codecov coverage report?

Yes, in Codecov coverage report also the same is happening.

@westonruter

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thelovekesh any ideas?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sarthak-19 can you please upload the xml coverage report? maybe that can help analyze how code coverage driver is looking for things?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -91,7 +91,7 @@ public function test_has_transparency_metadata( string $image_path, array $expec
*
* @dataProvider provider_get_dominant_color
*
* @covers ::dominant_color_get_dominant_color
* @covers helper::dominant_color_get_dominant_color
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @covers helper::dominant_color_get_dominant_color
* @covers ::dominant_color_get_dominant_color

@@ -113,7 +113,7 @@ public function test_dominant_color_has_transparency( string $image_path, array
*
* @dataProvider provider_get_dominant_color
*
* @covers ::dominant_color_img_tag_add_dominant_color
* @covers hooks::dominant_color_img_tag_add_dominant_color
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @covers hooks::dominant_color_img_tag_add_dominant_color
* @covers ::dominant_color_img_tag_add_dominant_color

@@ -199,7 +199,7 @@ public function data_dominant_color_img_tag_add_dominant_color_requires_proper_q
*
* @dataProvider data_provider_dominant_color_check_inline_style
*
* @covers ::dominant_color_img_tag_add_dominant_color
* @covers hooks::dominant_color_img_tag_add_dominant_color
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @covers hooks::dominant_color_img_tag_add_dominant_color
* @covers ::dominant_color_img_tag_add_dominant_color

@westonruter westonruter added the [Type] Enhancement A suggestion for improvement of an existing feature label Jan 31, 2025
@sarthak-19 sarthak-19 marked this pull request as ready for review February 1, 2025 07:17
Copy link

github-actions bot commented Feb 1, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @[email protected].

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: [email protected].

Co-authored-by: westonruter <[email protected]>
Co-authored-by: sarthak-19 <[email protected]>
Co-authored-by: thelovekesh <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no milestone PRs that do not have a defined milestone for release [Plugin] Image Placeholders Issues for the Image Placeholders plugin (formerly Dominant Color Images) skip changelog PRs that should not be mentioned in changelogs [Type] Enhancement A suggestion for improvement of an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants